package aybolit.core.objects.model;

import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Collection;

/**
 * Created by IntelliJ IDEA.
 * User: Vadim
 * Date: 13.03.13
 * Time: 16:57
 * To change this template use File | Settings | File Templates.
 */
@Entity
public class Departments implements Serializable {
    private int departmentId;

    @javax.persistence.Column(name = "department_id")
    @Id
    public int getDepartmentId() {
        return departmentId;
    }

    public void setDepartmentId(int departmentId) {
        this.departmentId = departmentId;
    }

    private int hospitalId;

    @javax.persistence.Column(name = "hospital_id")
    @Basic
    public int getHospitalId() {
        return hospitalId;
    }

    public void setHospitalId(int hospitalId) {
        this.hospitalId = hospitalId;
    }

    private String name;

    @javax.persistence.Column(name = "name")
    @Basic
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    private String note;

    @javax.persistence.Column(name = "note")
    @Basic
    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    private Timestamp timestamp;

    @javax.persistence.Column(name = "timestamp_")
    @Basic
    public Timestamp getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Timestamp timestamp) {
        this.timestamp = timestamp;
    }

    private int departamentStatus;

    @javax.persistence.Column(name = "departament_status")
    @Basic
    public int getDepartamentStatus() {
        return departamentStatus;
    }

    public void setDepartamentStatus(int departamentStatus) {
        this.departamentStatus = departamentStatus;
    }

    private int deleted;

    @javax.persistence.Column(name = "deleted")
    @Basic
    public int getDeleted() {
        return deleted;
    }

    public void setDeleted(int deleted) {
        this.deleted = deleted;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Departments that = (Departments) o;

        if (deleted != that.deleted) return false;
        if (departamentStatus != that.departamentStatus) return false;
        if (departmentId != that.departmentId) return false;
        if (hospitalId != that.hospitalId) return false;
        if (name != null ? !name.equals(that.name) : that.name != null) return false;
        if (note != null ? !note.equals(that.note) : that.note != null) return false;
        if (timestamp != null ? !timestamp.equals(that.timestamp) : that.timestamp != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = departmentId;
        result = 31 * result + hospitalId;
        result = 31 * result + (name != null ? name.hashCode() : 0);
        result = 31 * result + (note != null ? note.hashCode() : 0);
        result = 31 * result + (timestamp != null ? timestamp.hashCode() : 0);
        result = 31 * result + departamentStatus;
        result = 31 * result + deleted;
        return result;
    }

    private Collection<Chambers> chambersesByDepartmentId;

    @OneToMany(mappedBy = "departmentsByDepartamentId")
    public Collection<Chambers> getChambersesByDepartmentId() {
        return chambersesByDepartmentId;
    }

    public void setChambersesByDepartmentId(Collection<Chambers> chambersesByDepartmentId) {
        this.chambersesByDepartmentId = chambersesByDepartmentId;
    }

    private Hospitales hospitalesByHospitalId;

    @ManyToOne
    public
    @JoinColumn(name = "hospital_id", referencedColumnName = "hospital_id", table = "departments")
    Hospitales getHospitalesByHospitalId() {
        return hospitalesByHospitalId;
    }

    public void setHospitalesByHospitalId(Hospitales hospitalesByHospitalId) {
        this.hospitalesByHospitalId = hospitalesByHospitalId;
    }

    private Status statusByDepartamentStatus;

    @ManyToOne
    public
    @JoinColumn(name = "departament_status", referencedColumnName = "status_id", table = "departments")
    Status getStatusByDepartamentStatus() {
        return statusByDepartamentStatus;
    }

    public void setStatusByDepartamentStatus(Status statusByDepartamentStatus) {
        this.statusByDepartamentStatus = statusByDepartamentStatus;
    }

    private Collection<Operators> operatorsesByDepartmentId;

    @OneToMany(mappedBy = "departmentsByDepartmentId")
    public Collection<Operators> getOperatorsesByDepartmentId() {
        return operatorsesByDepartmentId;
    }

    public void setOperatorsesByDepartmentId(Collection<Operators> operatorsesByDepartmentId) {
        this.operatorsesByDepartmentId = operatorsesByDepartmentId;
    }

    private Collection<Patientes> patientesesByDepartmentId;

    @OneToMany(mappedBy = "departmentsByDepartmantId")
    public Collection<Patientes> getPatientesesByDepartmentId() {
        return patientesesByDepartmentId;
    }

    public void setPatientesesByDepartmentId(Collection<Patientes> patientesesByDepartmentId) {
        this.patientesesByDepartmentId = patientesesByDepartmentId;
    }
}
